#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
typedef unsigned long long ll;

ll maxn = 0;
int N = 0;
int M = 0;
ll sum = 0;
int main()
{
    cin >> N;
    for (int i = 1; i <= N; i++)
    {
        cin >> M;
        if (M > maxn)
        {
            sum += M;
            maxn = M;
        }
    }
    cout << sum << endl;
}